
package rendi456;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

public class Clavier implements KeyListener
{
	private final boolean[] touches;

	public Clavier()
	{
		this.touches = new boolean[300];
	}
	
	public boolean droite()
	{
		return this.touches[KeyEvent.VK_RIGHT];
	}
	
	public boolean gauche()
	{
		return this.touches[KeyEvent.VK_LEFT];
	}
	
	public boolean haut()
	{
		return this.touches[KeyEvent.VK_UP];
	}
	
	public boolean bas()
	{
		return this.touches[KeyEvent.VK_DOWN];
	}
	
	public boolean space()
	{
		return this.touches[KeyEvent.VK_SPACE];
	}

	@Override
	public void keyPressed(KeyEvent k)
	{
		int kcode = k.getKeyCode();
		if (!this.touches[kcode])
		{
			this.touches[kcode] = true;
		}
	}

	@Override
	public void keyReleased(KeyEvent k)
	{
		int kcode = k.getKeyCode();
		if (this.touches[kcode])
		{
			this.touches[kcode] = false;
		}
	}

	@Override
	public void keyTyped(KeyEvent k)
	{
		// TODO Auto-generated method stub

	}

}
